package com.ext.aic.components;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import com.ext.aic.R;
import com.ext.aic.enums.ShareType;
import com.eyinfo.android_pure_utils.events.Action1;
import com.eyinfo.android_pure_utils.utils.PixelUtils;
import com.lxj.xpopup.core.BottomPopupView;

import lombok.Setter;

public class SharePanelBottomPopup extends BottomPopupView {

    @Setter
    private Action1<ShareType> onShareClick;

    public SharePanelBottomPopup(Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.share_panel_layout;
    }

    @Override
    protected int getMaxHeight() {
        return PixelUtils.dip2px(getContext(), 180);
    }

    @Override
    protected void onCreate() {
        LinearLayout wechatLl = findViewById(R.id.wechat_ll);
        wechatLl.setOnClickListener(this::onWeChatShareClick);
        LinearLayout inStationLl = findViewById(R.id.in_station_ll);
        inStationLl.setOnClickListener(this::onInStationClick);
    }

    public void onInStationClick(View v) {
        if (onShareClick != null) {
            onShareClick.call(ShareType.InStation);
        }
        dismiss();
    }

    public void onWeChatShareClick(View v) {
        if (onShareClick != null) {
            onShareClick.call(ShareType.WeChat);
        }
        dismiss();
    }
}
